//
// Created by A4-28 on 2020/10/13.
//

#include "quaternion.h"

namespace WF {

    glm::quat Quaternion::EulerToQuaternion(glm::vec3 euler) {
        glm::mat4 matrix4x4 = glm::eulerAngleYXZ<float>(euler.y * DegreeToRadian, euler.x * DegreeToRadian,
                                                        euler.z * DegreeToRadian);
        return glm::toQuat(matrix4x4);
    }


    glm::vec3 Quaternion::QuaternionToEuler(glm::quat quaternion) {
        glm::vec3 euler = glm::eulerAngles(quaternion);
        return glm::vec3(euler.x * RadianToDegree, euler.y * RadianToDegree, euler.z * RadianToDegree);
    }

    glm::mat4 Quaternion::EulerToMatrix(glm::vec3 euler) {
        return glm::eulerAngleYXZ<float>(euler.y * DegreeToRadian, euler.x * DegreeToRadian,
                                         euler.z * DegreeToRadian);
    }
}